/*
 * Universidad Nacional de Colombia - Sede Bogotá *
 *
 *      David Montaño - damontanofe@unal.edu.co
 *      Laura Moreno - lvmorenoc@unal.edu.co
 *      Christian Rodriguez - carodriguezb@unal.edu.co
 *
 * Código liberado bajo licencia Creative Commons 3.0
 * http://creativecommons.org/licenses/by-nc-sa/3.0/
 */
package org.cripto.gui.sha1calc;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.PrintWriter;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.UnsupportedLookAndFeelException;
import org.cripto.gui.criptex.gui;
import org.cripto.authentication.HMacSHA1;
import org.cripto.hash.SHA1;

public class guiSHA extends javax.swing.JFrame {

    /** Creates new form guiSHA */
    public guiSHA() {
        initComponents();
        this.setIconImage(new ImageIcon(getClass().getResource("/org/cripto/gui/sha1calc//images/icon.png")).getImage());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        fondoTitulo = new javax.swing.JLabel();
        panelTexto = new javax.swing.JLayeredPane();
        panelCajaTexto = new javax.swing.JScrollPane();
        cajaTexto = new javax.swing.JTextArea();
        tituloTexto = new javax.swing.JLabel();
        botonLimpiar = new javax.swing.JButton();
        botonGuardar = new javax.swing.JButton();
        botonAbrir = new javax.swing.JButton();
        botonSalir = new javax.swing.JButton();
        botonAcercaDe = new javax.swing.JButton();
        panelHash = new javax.swing.JLayeredPane();
        hash2 = new javax.swing.JTextField();
        hash1 = new javax.swing.JTextField();
        hash2Texto = new javax.swing.JLabel();
        hash1Texto = new javax.swing.JLabel();
        calcular = new javax.swing.JButton();
        comparar = new javax.swing.JButton();
        panelHash1 = new javax.swing.JLayeredPane();
        MACTexto1 = new javax.swing.JLabel();
        calcMAC = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        hash3 = new javax.swing.JTextField();
        PanelKeyMAC = new javax.swing.JScrollPane();
        KeyMAC = new javax.swing.JTextArea();
        BotonGenerarClave = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Calculadora SHA-1");
        setBounds(new java.awt.Rectangle(300, 10, 0, 0));
        setResizable(false);

        fondoTitulo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/cripto/gui/sha1calc//images/fondoTituloSHA.png"))); // NOI18N

        cajaTexto.setColumns(20);
        cajaTexto.setRows(5);
        cajaTexto.setWrapStyleWord(true);
        panelCajaTexto.setViewportView(cajaTexto);

        panelCajaTexto.setBounds(0, 20, 782, 250);
        panelTexto.add(panelCajaTexto, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tituloTexto.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        tituloTexto.setText("Ingrese o cargue un texto para calcularle el HASH");
        tituloTexto.setBounds(0, 0, 780, 20);
        panelTexto.add(tituloTexto, javax.swing.JLayeredPane.DEFAULT_LAYER);

        botonLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/cripto/gui/sha1calc//images/limpiar.png"))); // NOI18N
        botonLimpiar.setToolTipText("Limpiar o reiniciar caja de texto");
        botonLimpiar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        botonLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonLimpiarActionPerformed(evt);
            }
        });
        botonLimpiar.setBounds(797, 110, 40, 40);
        panelTexto.add(botonLimpiar, javax.swing.JLayeredPane.DEFAULT_LAYER);

        botonGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/cripto/gui/sha1calc//images/guardar.png"))); // NOI18N
        botonGuardar.setToolTipText("Guardar a un archivo");
        botonGuardar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        botonGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonGuardarActionPerformed(evt);
            }
        });
        botonGuardar.setBounds(797, 60, 40, 40);
        panelTexto.add(botonGuardar, javax.swing.JLayeredPane.DEFAULT_LAYER);

        botonAbrir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/cripto/gui/sha1calc//images/abrir.png"))); // NOI18N
        botonAbrir.setToolTipText("Abrir un archivo");
        botonAbrir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        botonAbrir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonAbrirActionPerformed(evt);
            }
        });
        botonAbrir.setBounds(797, 10, 40, 40);
        panelTexto.add(botonAbrir, javax.swing.JLayeredPane.DEFAULT_LAYER);

        botonSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/cripto/gui/sha1calc//images/salir.png"))); // NOI18N
        botonSalir.setToolTipText("Salir");
        botonSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonSalirActionPerformed(evt);
            }
        });
        botonSalir.setBounds(797, 230, 40, 40);
        panelTexto.add(botonSalir, javax.swing.JLayeredPane.DEFAULT_LAYER);

        botonAcercaDe.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/cripto/gui/sha1calc//images/creditos.png"))); // NOI18N
        botonAcercaDe.setToolTipText("Acerca de..");
        botonAcercaDe.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        botonAcercaDe.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonAcercaDeActionPerformed(evt);
            }
        });
        botonAcercaDe.setBounds(797, 180, 40, 40);
        panelTexto.add(botonAcercaDe, javax.swing.JLayeredPane.DEFAULT_LAYER);

        panelHash.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        hash2.setFont(new java.awt.Font("Tahoma", 0, 14));
        hash2.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        hash2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hash2ActionPerformed(evt);
            }
        });
        hash2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                hash2KeyTyped(evt);
            }
        });
        hash2.setBounds(15, 135, 380, 25);
        panelHash.add(hash2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        hash1.setEditable(false);
        hash1.setFont(new java.awt.Font("Tahoma", 0, 14));
        hash1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        hash1.setBounds(15, 35, 380, 25);
        panelHash.add(hash1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        hash2Texto.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        hash2Texto.setText("HASH 2 - Ingrese un HASH para compararlo con el HASH 1");
        hash2Texto.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        hash2Texto.setBounds(15, 115, 380, 20);
        panelHash.add(hash2Texto, javax.swing.JLayeredPane.DEFAULT_LAYER);

        hash1Texto.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        hash1Texto.setText("HASH 1");
        hash1Texto.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        hash1Texto.setBounds(15, 15, 380, 20);
        panelHash.add(hash1Texto, javax.swing.JLayeredPane.DEFAULT_LAYER);

        calcular.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/cripto/gui/sha1calc//images/footprint.png"))); // NOI18N
        calcular.setText("Calcular HASH SHA-1");
        calcular.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                calcularActionPerformed(evt);
            }
        });
        calcular.setBounds(15, 65, 380, 35);
        panelHash.add(calcular, javax.swing.JLayeredPane.DEFAULT_LAYER);

        comparar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/cripto/gui/sha1calc//images/footprintCompare.png"))); // NOI18N
        comparar.setText("Comparar dos HASH SHA-1");
        comparar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                compararActionPerformed(evt);
            }
        });
        comparar.setBounds(15, 168, 380, 35);
        panelHash.add(comparar, javax.swing.JLayeredPane.DEFAULT_LAYER);

        panelHash1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        MACTexto1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        MACTexto1.setText("Ingrese una llave HMAC en formato HEXA");
        MACTexto1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        MACTexto1.setBounds(15, 10, 380, 20);
        panelHash1.add(MACTexto1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        calcMAC.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/cripto/gui/sha1calc//images/hmac.png"))); // NOI18N
        calcMAC.setText("Calcular HMAC");
        calcMAC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                calcMACActionPerformed(evt);
            }
        });
        calcMAC.setBounds(15, 173, 380, 30);
        panelHash1.add(calcMAC, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("HMAC SHA-1");
        jLabel1.setBounds(15, 125, 380, 18);
        panelHash1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        hash3.setEditable(false);
        hash3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        hash3.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        hash3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hash3ActionPerformed(evt);
            }
        });
        hash3.setBounds(15, 143, 380, 23);
        panelHash1.add(hash3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        KeyMAC.setColumns(20);
        KeyMAC.setFont(new java.awt.Font("Monospaced", 0, 12)); // NOI18N
        KeyMAC.setLineWrap(true);
        KeyMAC.setRows(2);
        KeyMAC.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                KeyMACKeyTyped(evt);
            }
        });
        PanelKeyMAC.setViewportView(KeyMAC);

        PanelKeyMAC.setBounds(15, 30, 380, 60);
        panelHash1.add(PanelKeyMAC, javax.swing.JLayeredPane.DEFAULT_LAYER);

        BotonGenerarClave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/cripto/gui/sha1calc//images/clave.png"))); // NOI18N
        BotonGenerarClave.setText("Generar una clave");
        BotonGenerarClave.setToolTipText("Generar una clave");
        BotonGenerarClave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonGenerarClaveActionPerformed(evt);
            }
        });
        BotonGenerarClave.setBounds(15, 96, 380, 25);
        panelHash1.add(BotonGenerarClave, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panelTexto, javax.swing.GroupLayout.PREFERRED_SIZE, 838, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(panelHash, javax.swing.GroupLayout.PREFERRED_SIZE, 411, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(15, 15, 15)
                        .addComponent(panelHash1, javax.swing.GroupLayout.DEFAULT_SIZE, 412, Short.MAX_VALUE)))
                .addGap(15, 15, 15))
            .addComponent(fondoTitulo, javax.swing.GroupLayout.DEFAULT_SIZE, 868, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(fondoTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addComponent(panelTexto, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(panelHash)
                    .addComponent(panelHash1, javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE))
                .addGap(14, 14, 14))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botonLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonLimpiarActionPerformed
        
        cajaTexto.setText("");
}//GEN-LAST:event_botonLimpiarActionPerformed

    private void botonGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonGuardarActionPerformed
        
        
        JFileChooser chooser = new JFileChooser();
        chooser.addChoosableFileFilter(new TxTFilter());
        chooser.showSaveDialog(this);
        File archivo = chooser.getSelectedFile();
        try {
            PrintWriter writer = new PrintWriter(archivo);
            writer.print(cajaTexto.getText());
            writer.close();
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
}//GEN-LAST:event_botonGuardarActionPerformed

    private void botonAbrirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonAbrirActionPerformed
        
        JFileChooser chooser = new JFileChooser();
        chooser.addChoosableFileFilter(new TxTFilter());
        chooser.showOpenDialog(this);
        File archivo = chooser.getSelectedFile();
        try {
            BufferedReader reader = new BufferedReader(new FileReader(archivo));
            String linea = "";
            String texto = "";
            while ((linea = reader.readLine()) != null) {
                texto = texto.concat(linea).concat("\n");
            }
            reader.close();
            cajaTexto.setText(texto);
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
}//GEN-LAST:event_botonAbrirActionPerformed
    private boolean validarHASH(String text) {
        if (text.length() != 40) {
            JOptionPane.showMessageDialog(this, "Asegurese de que el HASH ingresado posea una longitud igual a 40", "Error: Comparación HASH", JOptionPane.ERROR_MESSAGE);
            return false;
        }
        boolean valida = true;
        for (int character = 0; character <= 47; character++) {
            if (text.indexOf((char) character) != -1) {
                valida = false;
            }
        }
        for (int character = 58; character <= 64; character++) {
            if (text.indexOf((char) character) != -1) {
                valida = false;
            }
        }
        for (int character = 91; character <= 96; character++) {
            if (text.indexOf((char) character) != -1) {
                valida = false;
            }
        }
        for (int character = 123; character <= 255; character++) {
            if (text.indexOf((char) character) != -1) {
                valida = false;
            }
        }
        if (!valida) {
            JOptionPane.showMessageDialog(this, "Asegurese de que el HASH solo contiene carácteres hexadecimales", "Error: Comparación HASH", JOptionPane.ERROR_MESSAGE);
            return false;
        }
        return true;
    }
    private void compararActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_compararActionPerformed
        
        if (cajaTexto.getText().length() != 0) {
            if (validarHASH(hash2.getText())) {
                if (hash1.getText().equals(hash2.getText().toLowerCase())) {
                    JOptionPane.showMessageDialog(this, "El texto posee el mismo HASH que el ingresado", "Comparación HASH", JOptionPane.INFORMATION_MESSAGE);
                } else {
                    JOptionPane.showMessageDialog(this, "El texto posee diferente HASH que el ingresado", "Comparación HASH", JOptionPane.WARNING_MESSAGE);
                }
            }
        } else {
            JOptionPane.showMessageDialog(this, "Asegúrese de haber ingresado un texto al cual calcularle el HASH", "Error: Comparación HASH", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_compararActionPerformed

    private void botonSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonSalirActionPerformed
        
        System.exit(0);
}//GEN-LAST:event_botonSalirActionPerformed

    private void botonAcercaDeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonAcercaDeActionPerformed
        
        JOptionPane.showMessageDialog(this,
                "Realizado por:\n"
                + "\nDavid Montaño Fetecua - damontanofe@unal.edu.co"
                + "\nLaura Moreno Cubillos - lvmorenoc@unal.edu.co"
                + "\nChristian Rodríguez Bustos - carodriguezb@unal.edu.co\n",
                "Acerca de...",
                JOptionPane.INFORMATION_MESSAGE);
}//GEN-LAST:event_botonAcercaDeActionPerformed

    private void hash2KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_hash2KeyTyped
        
        char c = evt.getKeyChar();
        c = String.valueOf(c).toUpperCase().charAt(0);
        if (c != 'A' && c != 'B' && c != 'C' && c != 'D' && c != 'E' && c != 'F' && !Character.isDigit(c) || hash2.getText().length() == 40) {
            evt.consume();

        } else {
            if (Character.isLowerCase(c)) {
                c = Character.toUpperCase(c);
                hash2.setText(hash2.getText().concat(String.valueOf(c)));
                evt.consume();
            }
        }
}//GEN-LAST:event_hash2KeyTyped

    private void calcularActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_calcularActionPerformed
        String hash = SHA1.hash(cajaTexto.getText());

        hash1.setText(hash);

    }//GEN-LAST:event_calcularActionPerformed

    private void calcMACActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_calcMACActionPerformed
        try {
            String MAC = HMacSHA1.hash(cajaTexto.getText(), KeyMAC.getText());
            hash3.setText(MAC);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Asegúrese de haber ingresado una clave válida.\nRecuerde que la clave debe ser de 128 carácteres\nhexadecimales o pruebe pulsando el botón\nGenerar clave.", "Error al calcular el HMAC", JOptionPane.ERROR_MESSAGE);
            System.out.println("err " + e.getMessage());
        }


}//GEN-LAST:event_calcMACActionPerformed

    private void hash2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hash2ActionPerformed
        
    }//GEN-LAST:event_hash2ActionPerformed

    private void KeyMACKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_KeyMACKeyTyped
        char c = evt.getKeyChar();
        boolean isUpCase = Character.isUpperCase(c);
        c = String.valueOf(c).toUpperCase().charAt(0);
        if ((KeyMAC.getText().length() + 1) > 128) {
            evt.consume();
        } else if (c != 'A' && c != 'B' && c != 'C' && c != 'D' && c != 'E' && c != 'F' && !Character.isDigit(c) || hash2.getText().length() == 40) {
            evt.consume();
        } else if (isUpCase) {
            c = Character.toLowerCase(c);
            KeyMAC.setText(KeyMAC.getText().concat(String.valueOf(c)));
            evt.consume();
        }
    }//GEN-LAST:event_KeyMACKeyTyped

    private void BotonGenerarClaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonGenerarClaveActionPerformed
        Random rnd = new Random();
        String clave = "";
        String[] hexa = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};

        // Clave aleatoria
        clave = "";
        while (clave.length() != 128) {
            clave = clave.concat(hexa[rnd.nextInt(16)]);
        }
        KeyMAC.setText(clave);
}//GEN-LAST:event_BotonGenerarClaveActionPerformed

    private void hash3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hash3ActionPerformed
        
    }//GEN-LAST:event_hash3ActionPerformed
    public class TxTFilter extends javax.swing.filechooser.FileFilter {

        final static String txt = "txt";

        /** Creates a new instance of XMLFilter */
        public TxTFilter() {
        }

        public boolean accept(File f) {
            if (f.isDirectory()) {
                return true;
            }
            String s = f.getName();
            int i = s.lastIndexOf('.');

            if (i > 0 && i < s.length() - 1) {
                String extension = s.substring(i + 1).toLowerCase();
                if (txt.equals(extension)) {
                    return true;
                } else {
                    return false;
                }
            }
            return false;
        }

        public String getDescription() {
            return "archivos .txt";
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {
                    UIManager.setLookAndFeel("org.pushingpixels.substance.api.skin.SubstanceBusinessBlackSteelLookAndFeel");
                } catch (Exception e) {
                    try {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    } catch (ClassNotFoundException ex) {
                        Logger.getLogger(gui.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (InstantiationException ex) {
                        Logger.getLogger(gui.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (IllegalAccessException ex) {
                        Logger.getLogger(gui.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (UnsupportedLookAndFeelException ex) {
                        Logger.getLogger(gui.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
                new guiSHA().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BotonGenerarClave;
    private javax.swing.JTextArea KeyMAC;
    private javax.swing.JLabel MACTexto1;
    private javax.swing.JScrollPane PanelKeyMAC;
    private javax.swing.JButton botonAbrir;
    private javax.swing.JButton botonAcercaDe;
    private javax.swing.JButton botonGuardar;
    private javax.swing.JButton botonLimpiar;
    private javax.swing.JButton botonSalir;
    private javax.swing.JTextArea cajaTexto;
    private javax.swing.JButton calcMAC;
    private javax.swing.JButton calcular;
    private javax.swing.JButton comparar;
    private javax.swing.JLabel fondoTitulo;
    private javax.swing.JTextField hash1;
    private javax.swing.JLabel hash1Texto;
    private javax.swing.JTextField hash2;
    private javax.swing.JLabel hash2Texto;
    private javax.swing.JTextField hash3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane panelCajaTexto;
    private javax.swing.JLayeredPane panelHash;
    private javax.swing.JLayeredPane panelHash1;
    private javax.swing.JLayeredPane panelTexto;
    private javax.swing.JLabel tituloTexto;
    // End of variables declaration//GEN-END:variables
}
